﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>界面自句柄 - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The 界面自句柄 function retrieves the 界面 对象 of a 界面 window associated with the specified HWND." />
<meta name="ahk:equiv-v1" content="commands/Gui.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css">
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>界面自句柄</h1>

<p>检索与指定的 HWND 关联的 界面 窗口的 <a href="../objects/Gui.htm">界面 对象</a>.</p>
<pre class="Syntax">GuiObj := <span class="func">界面自句柄</span>(Hwnd <span class="optional">, RecurseParent := false</span>)</pre>

<h2 id="Parameters">参数</h2>
<dl>
  <dt>Hwnd</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
    <p>界面 窗口的窗口句柄(HWND). 这样的窗口可以用 <a href="../objects/Gui.htm#New">界面.新建</a> 创建.</p>
  </dd>
  <dt>RecurseParent</dt>
  <dd>
    <p>类型: <a href="../Concepts.htm#boolean">整数(布尔值)</a></p>
    <p>如果该参数为 1(true), 则会自动搜索并检索与指定的 HWND 最接近的父级(即 GUI).</p>
  </dd>
</dl>
  
<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#objects">对象</a></p>
<p>此函数返回对现有 <a href="../objects/Gui.htm">界面 对象</a>的<a href="../Concepts.htm#references-to-objects">引用</a>. 该对象提供了用于创建和管理窗口以及创建控件的方法和属性. </p>

<h2 id="Remarks">备注</h2>
<p>例如, 可以通过 <a href="../objects/Gui.htm#Hwnd">Gui.Hwnd</a>, <a href="WinExist.htm">窗口存在</a> 或 <a href="WinGetID.htm">获取窗口句柄</a> 检索 界面 窗口的 HWND.</p>

<h2 id="Related">相关</h2>
<p><a href="../objects/Gui.htm#New">界面.新建</a>, <a href="../objects/Gui.htm">界面 对象</a>, <a href="../objects/GuiControl.htm">界面控件 对象</a>, <a href="GuiCtrlFromHwnd.htm">界面控件自句柄</a>, <a href="GuiControls.htm">Control 类型</a>, <a href="ListView.htm">ListView</a>, <a href="TreeView.htm">TreeView</a>, <a href="../objects/Menu.htm">Menu 对象</a>, <a href="Control.htm">Control 函数</a>, <a href="MsgBox.htm">信息框</a>, <a href="FileSelect.htm">文件选择框</a>, <a href="DirSelect.htm">目录选择框</a></p>

<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>MyGui := 界面.新建(, "Title of Window")
MyGui.Add("Text",, "Some text to display.")
MyGui.显示()

信息框(界面自句柄(Gui.Hwnd).Title)</pre>
</div>

</body>
</html>